#!/bin/bash

CREATEPIPE=0x00000200
EXECCMD=0x00000400
CALLAPI=0x00000800

create_pipe() {
    echo "[INFO] Creating a pipe for communication."
    pipe_file="/tmp/pipe_$$"
    mkfifo "$pipe_file"
    echo "[INFO] Pipe created at: $pipe_file"
}

exec_cmd() {
    echo "[INFO] Executing command: ls -l"
    ls -l
}

call_api() {
    echo "[INFO] Simulating API call to https://api.example.com/data"
    response=$(curl -s https://api.example.com/data || echo "API call failed")
    echo "[INFO] API response: $response"
}

while true; do
    echo "Select an operation:"
    echo "1. CREATEPIPE"
    echo "2. EXECCMD"
    echo "3. CALLAPI"
    echo "4. Exit"
    read -rp "Enter your choice: " choice

    case $choice in
        1)
            create_pipe
            ;;
        2)
            exec_cmd
            ;;
        3)
            call_api
            ;;
        4)
            echo "[INFO] Exiting program."
            break
            ;;
        *)
            echo "[ERROR] Invalid choice. Please try again."
            ;;
    esac

done
